﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Runtime.InteropServices;
using System.IO;
using System.Xml.Linq;
using System.Diagnostics;


namespace NETCommon.Files
{
    public class NSimpleIniFile
    {
        public string m_strPath;

        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

        public NSimpleIniFile(string INIPath)
        {
            m_strPath = INIPath;
        }
        public void IniWriteValue(string strSection, string strKey, string strValue)
        {
            WritePrivateProfileString(strSection, strKey, strValue, this.m_strPath);
        }
        public string IniReadValue(string strSection, string strKey)
        {
            StringBuilder valStr = new StringBuilder(255);

            GetPrivateProfileString(strSection, strKey, "", valStr, 255, this.m_strPath);

            return valStr.ToString();
        }
    }
}